#!/bin/sh

v_install_path="/usr/local/atwork/"

v_install_store_path="/tmp/atwork/"

v_install_dir="apache-tomcat-8.0.12"

v_install_file="apache-tomcat-8.0.12.zip"

echo "=======install tomcat==========="
#检测安装目录是否存在，如果不存在则创建
f_install_path_check(){
 if [ ! -d "$v_install_path" ]; then
   mkdir -p "$v_install_path"
 fi
}

#检查TOMCAT安装文件是否存在
f_install_file_exists(){
 if [ ! -f "${v_install_store_path}${v_install_file}" ]; then
   echo "install file not exists:${v_install_store_path}${v_install_file}"
   exit 1
 fi
}

f_install_tomcat(){
  unzip ${v_install_store_path}${v_install_file} -d $v_install_path
  rm -rf "${v_install_path}${v_install_dir}/webapps"
  mkdir -p "${v_install_path}${v_install_dir}/webapps"
}

f_install_path_check

f_install_file_exists

f_install_tomcat

echo "=======install tomcat OK========"
